package com.cheryjb.examples.gwt.clock.client;

import com.google.gwt.dom.client.ImageElement;
import com.google.gwt.user.client.ui.Image;

/**
 * Needle type: HOURS, MINUTES, OR SECOND<br>
 * Take the image url in parameter, and provide a method to retrieve the
 * corresponding ImageElement.
 * 
 * @author Jean-Baptiste Chery
 * 
 */
public enum NeedleType {

	HOURS("needle_hours.png"), MINUTES("needle_minutes.png"), SECONDS(
			"needle_seconds.png");

	/**
	 * ImageElement that will be displayed in the Canvas
	 */
	private ImageElement image;

	/**
	 * Initiate the ImageElement from the url given in paremeter
	 * 
	 * @param url
	 */
	NeedleType(final String url) {
		image = new Image(url).getElement().cast();
	}

	/**
	 * @return the image element to be displayed on the Canvas
	 */
	public ImageElement getImage() {
		return image;
	}
}
